// +----------------------------------------------------------------------
// | Project:   Commons  
// +----------------------------------------------------------------------
// | CreateTime: 15/11/3  下午2:32
// +----------------------------------------------------------------------
// | Author:     xab(xab@xabad.cn)
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
package cn.xabad.commons.tools;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;


/**
 * DESC   :
 * AUTHOR : Xabad
 */
public class VersionU {

    public static String getVersionInfo(Context context) {
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(),
                    PackageManager.GET_CONFIGURATIONS);
            if (info != null) {
                return info.versionName + "( " + info.versionCode + " )";
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
        return null;
    }

    public static String getVersionName(Context context) {
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(),
                    PackageManager.GET_CONFIGURATIONS);
            if (info != null) {
                return info.versionName;
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
        return null;
    }
}
